#!/usr/bin/env python
# coding=utf-8
# Created by han on 2016/6/5
import os,sys,platform,json
if platform.system() == 'Windows':
    BASE_DIR = '\\'.join(os.path.dirname(__file__).split('/')[:-1])
else:
    BASE_DIR = '/'.join(os.path.dirname(__file__).split('/')[:-1])
sys.path.append(BASE_DIR)

a = "abbb"
a.startswith('')
from conf import db_conf

def login():
    pass


def manage():
    db_list = os.listdir(db_conf.DB_BASE)
    new_db_list = filter(lambda x:"root"  in x,db_list)
    if not new_db_list:
        root = {"user":"root","pass":"root"}
        json.dump(root,open("root",'w',encoding="utf-8"))
    user_input = input("请输入管理员用户名： ")

def user_auth(*args,**kwargs):
    pass



#
# a = manage()


# {"user":"hanxu","lock":"1","money":{"available":8888,"unsettled":{"5.10":10},"out":{"10":200},"interest":0}}
# {"user":"hanxu","lock":"1","money":{"available":8888,"unsettled":{"5.22":20},"out":{"10":200}}}
# {"user":"hanxu","lock":"1","money":{"available":8888,"unsettled":{"5.23":0},"out":{"6.10":30},"interest":0}}
                                                                                                              #"时间差*0.5*out"
a = {"money":{"available":8888,"unsettled":{"7.22":0},"out":{"8.10":20},"interest":5,"return":10},"interest_raw":60}
return == interst_raw   将连个数值归零

如果 unsttled【date】 == 当月的22日 则将未出账单放入 out中
还钱金额如果等于out 则直接清零并将钱放入avaliable中
如果还钱金额小于out 则放入return中
     如果return  == out 就将这两个值清空，并将对应的钱放入avaiable中
      如果到了还款日 return ！= out 则将out金额放入 interest_raw中，并将out清空
        则利息由intersta_raw 计算
        如果有利息则先将还款金额与利息相减，如果还款金额大于inter_raw-return+instert,直接将这3个值空青，并将多余的钱与available相加。
如果还钱金额大于out 则将out清零，并将差额转入avaliable中
unsettled 日期随着系统时间前进
out的时间在与unsettled时间相等时增加一个月，一开始out的时间要通过unserttled时间判断，如果unsettled时间大于22日，则 out时间为unserttled月+2.10号
                                                                           如果unsettled时间小于22日 则out时间为unsertteld月—+1.10号
a = {"avaliable":0,"unsettled":{"当前时间":0},"out":{0:0},"interest":0,"return":0,"interest_raw":0}



# {"user":"hanxu","lock":"1","money":{"available":8888,"unsettled":{"6.23":10},"out":{"7.10":10},"interest":0}}
msg = "用户:{user}\n可用额度：{money[available]}\n已出账单：{money[out][6.10]}\n应还金额：{money[interest]}+{money[out][6.10]}".format(**a)
print(msg)

# msg = "今天：{name}".format(name=123)
# print(msg)